const path = require('path')
var webpack = require('webpack')
const resolve = function (dir) {
  return path.join(__dirname, dir)
}

// 缩小打包之后的大小
// const CompressionWebpackPlugin = require('compression-webpack-plugin')
// const productionGzipExtensions = ['js', 'css']

module.exports = {
  publicPath: '/kDemo',
  outputDir: 'dist',
  assetsDir: 'static',
  lintOnSave: false,
  // productionSourceMap: true,
  devServer: {
    port: '8080',
    open: true
  },
  // configureWebpack: {
  //   resolve: {
  //     alias: {
  //       '@': path.resolve(__dirname, './src'),
  //       'views': path.resolve(__dirname, './src/views'),
  //     }
  //   },
  //   plugins: [
  //     new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
  //     new CompressionWebpackPlugin({
  //       algorithm: 'gzip',
  //       test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  //       threshold: 10240,
  //       minRatio: 0.8
  //     }),
  //     new webpack.optimize.LimitChunkCountPlugin({
  //       maxChunks: 5,
  //       minChunkSize: 100
  //     })
  //   ],
  //   optimization: {
  //     splitChunks: {
  //       automaticNameDelimiter: '-',
  //       chunks: 'all',
  //       cacheGroups: {
  //         chunk: {
  //           name: 'vab-chunk',
  //           test: /[\\/]node_modules[\\/]/,
  //           minSize: 131072,
  //           maxSize: 524288,
  //           chunks: 'async',
  //           minChunks: 2,
  //           priority: 10,
  //         },
  //         vue: {
  //           name: 'vue',
  //           test: /[\\/]node_modules[\\/](vue(.*)|core-js)[\\/]/,
  //           chunks: 'initial',
  //           priority: 20,
  //         },
  //         elementUI: {
  //           name: 'element-ui',
  //           test: /[\\/]node_modules[\\/]element-ui(.*)[\\/]/,
  //           priority: 30,
  //         },
  //         vant: {
  //           name: 'vant',
  //           test: /[\\/]node_modules[\\/]vant(.*)[\\/]/,
  //           priority: 30,
  //         },
  //         print: {
  //           name: 'print',
  //           test: /[\\/]node_modules[\\/](vue-print-nb|other-print-lib)[\\/]/,
  //           priority: 30
  //         },
  //       },
  //     },
  //   },    
  // },
  // chainWebpack: config => {
  //   config.optimization.minimizer('terser').tap((args) => {
  //     args[0].terserOptions.compress.drop_console = true
  //     return args
  //   })
  // }
}
